﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3_BaseKeyWord
{
    public class Asset
    {
        public string Name;
        //Liability债务属性
        public virtual decimal Liability => 1;  //表达体属性
    }

    public class Stock : Asset
    {
        public long SharesOwned;
    }
    public class House : Asset
    {
        public decimal Mortgage;

        //base关键字访问Asset类对Liability的实现
        //public override decimal Liability => base.Liability + Mortgage;

        //隐藏属性也同样生效
        public new decimal Liability => base.Liability + Mortgage;
    }
    class Chapt3_2_7BaseKeyWord
    {
        static void _Main()
        {
            Asset a;
            House h = new House();
            a = h;
            h.Mortgage = 250000;
            Console.WriteLine($"子类调用 : house.Liability:{h.Liability}");
            Console.WriteLine($"基类调用 : house.Liability:{a.Liability}");          
        }
    }
}
